"""
Boot Option api
"""


import json

from .command import integrated_command
from .argument import build_args
from redfishtoollib import main


# set boot options to Once Cd UEFI
def boot_to_cd_once_with_uefi():
    args = build_args()
    cmd = integrated_command(args, 'Systems', '--all', 'setBootOverride', 'Once', 'Cd')
    res = main(cmd)
    try:
        boot = json.loads(res)
    except ValueError:
        boot = {}
    if boot.get('Boot', {}).get('BootSourceOverrideMode') == 'UEFI' and boot.get('Boot', {}).get('BootSourceOverrideEnabled') == 'Once' and boot.get('Boot', {}).get('BootSourceOverrideTarget') == 'Cd':
        print('Success')